package main;

import utils.Utility;
import constants.Constants;
import domain.BioRecord;
import domain.InsRecord;
import domain.MkvRecord;
import domain.PolRecord;
import domain.RpoRecord;

public class WriteFunction {
	public static void writeFunction(int maxt, BioRecord bio, MkvRecord mkv, RpoRecord rpo, PolRecord pol){
		System.out.printf("");
		
		int sea = bio.getStart_sea();
		double sumcash = 0.0;
		
		for(int t = 1; t <= 140; t++) System.out.printf("%d ",t);
		System.out.printf("\n%s %d\n%s\n","BioFile",bio.getAnalysis(),"Some Time");
		System.out.printf("t ");
		System.out.printf("sea ");
		System.out.printf("operating_cash ");
		System.out.printf("total_cash ");
		System.out.printf("sumcash ");
		System.out.printf("milkyield ");
		System.out.printf("discount ");
		System.out.printf("calves_born ");
		System.out.printf("heifers_purchased ");
		System.out.printf("heifers_raised ");
		//10
		System.out.printf("heifers_sold ");
		System.out.printf("heiferpool ");
		System.out.printf("keep ");
		System.out.printf("pind ");
		System.out.printf("repl ");
		System.out.printf("open ");
		System.out.printf("preg ");
		System.out.printf("milking ");
		System.out.printf("present ");
		System.out.printf("milksales ");
		//20
		System.out.printf("cwt ");
		System.out.printf("feedcost ");
		System.out.printf("cullprice ");
		System.out.printf("calfsales ");
		System.out.printf("cowsales ");
		System.out.printf("heiferpurchasecost ");
		System.out.printf("calvinginterval_clvlact ");			
		System.out.printf("calvinginterval_clvsea ");		//my month of 1st calving	
		System.out.printf("daystoconception_clvlact ");	
		System.out.printf("daystoconception_clvsea ");			
		//30
		System.out.printf("feedcost_wet_mim ");
		System.out.printf("repl_clv ");
		System.out.printf("smy_curr ");					
		System.out.printf("smy_ave ");
		System.out.printf("pind_clv ");
		System.out.printf("dayslbm_curr ");
		System.out.printf("delayed ");
		System.out.printf("serv ");
		System.out.printf("serv_keep ");				
		System.out.printf("lactation1 ");
		//40
		System.out.printf("lactation2 ");
		System.out.printf("mkv_enter ");
		System.out.printf("open_dim ");
		System.out.printf("preg_dim ");
		System.out.printf("%%open ");
		System.out.printf("%%preg ");
		System.out.printf("calved ");
		System.out.printf("fixedcost ");
		System.out.printf("saldo ");
		System.out.printf("milkyield_mcow_d ");
		//50
		System.out.printf("feedcost_lact ");	
		System.out.printf("insval_mim ");
		System.out.printf("rpo ");
		System.out.printf("inv ");
		System.out.printf("vol ");
		System.out.printf("insval_sea ");
		System.out.printf("daysfirstservice_curr ");
		System.out.printf("daystoconception_curr ");		//repl_yield
		System.out.printf("hz_open_repl ");
		System.out.printf("hz_open_pind ");
		//60
		System.out.printf("hz_preg_repl ");
		System.out.printf("hz_preg_pind ");
		System.out.printf("replopen_mlk[mim] ");
		System.out.printf("replopen_mlk[t] ");
		System.out.printf("daysvwp_curr ");
		System.out.printf("dim ");
		System.out.printf("totrevenue ");
		System.out.printf("totcost ");
		System.out.printf("replopen_dim[mim] ");
		System.out.printf("replopen_dim[t] ");
		//70
		System.out.printf("replopen_cur[mim] ");
		System.out.printf("replopen_cur[t] ");
		System.out.printf("replopen_rev[mim] ");
		System.out.printf("replopen_rev[t] ");
		System.out.printf("replopen_iof[mim] ");
		System.out.printf("replopen_iof[t] ");
		System.out.printf("replopen_rpo[mim] ");
		System.out.printf("replopen_rpo[t] ");
		System.out.printf("daysopencost_dim ");
		System.out.printf("dmi_mcow_d ");
		//80
		System.out.printf("dmi_mim ");
		System.out.printf("dayspregcost_mim ");
		System.out.printf("lactationcurve ");
		System.out.printf("milkingcows_mim ");
		System.out.printf("cows_lact ");
		System.out.printf("hz_cull_mim ");
		System.out.printf("pctcull_mim ");
		System.out.printf("breedingsupplycost ");
		System.out.printf("pv_curr ");
		System.out.printf("pv_lact ");
		//90
		System.out.printf("pv_mim ");
		System.out.printf("pv_mpreg ");
		System.out.printf("pv_t_open ");
		System.out.printf("pv_t_preg ");
		System.out.printf("labortime ");
		System.out.printf("laborcost ");
		System.out.printf("calvinginterval ");			//by month of second calving
		System.out.printf("daystoconc ");
		System.out.printf("pv_curr_lact ");
		System.out.printf("opportunitycost ");
		//100
		System.out.printf("cowvalue ");
		System.out.printf("pind_rpo_curr ");
		System.out.printf("pind_rpo_lact ");
		System.out.printf("pind_rpo_mim ");
		System.out.printf("pind_rpo_mpreg ");
		System.out.printf("daysvwp_clvlact ");	
		System.out.printf("daysvwp_clvsea ");			
		System.out.printf("dvwp ");
		System.out.printf("daysfs_clvlact ");	
		System.out.printf("daysfs_clvsea ");			
		//110
		System.out.printf("dfs ");
		System.out.printf("dayslbm_clvlact ");	
		System.out.printf("dayslbm_clvsea ");			
		System.out.printf("dlbm ");
		System.out.printf("present_dim ");
		System.out.printf("breedings1 ");
		System.out.printf("dryoffyield ");
		System.out.printf("breedings ");
		System.out.printf("eligible_keep_mim ");
		System.out.printf("eligible_serv_mim ");
		//120
		System.out.printf("eligible_bred_mim ");
		System.out.printf("eligible_preg_mim ");
		System.out.printf("keep_rev0 ");
		System.out.printf("mim ");
		System.out.printf("rpo ");
		System.out.printf("iofc ");
		System.out.printf("rev ");
		System.out.printf("milkyld ");
		System.out.printf("pregval ");
		System.out.printf("feedefficiency ");
		//130
		System.out.printf("feedcost ");
		System.out.printf("varcost ");
		System.out.printf("pol ");
		System.out.printf("bio_pmilk ");
		System.out.printf("bio_pheifer ");

		/////////////////////////////////////////////////////////////////////////////////////////////
		for(int t = 1; t <= Constants.MAXM; t++)
		{
			if(t>72) continue;
			
			System.out.printf("\n%d ",t);
			System.out.printf("%d ",sea);
			if(t <= maxt) System.out.printf("%f ",mkv.getRev()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getCash()[t]); else System.out.printf("X ");
			sumcash += mkv.getCash()[t]; if(t <= maxt) System.out.printf("%f ",sumcash); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getMilkyield()[0][t]/Constants.STAGE); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",Utility.discount(bio.getInterest()/12,(double)t-1)); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getCalves_born()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getHeifers_purchased()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getHeifers_raised()[t]); else System.out.printf("X ");
			//10
			if(t <= maxt) System.out.printf("%f ",mkv.getHeifers_sold()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getHeiferpool()[t]); else System.out.printf("X ");
			System.out.printf("X ");	//,mkv.getkeep[0][t]);  keep[curr][t] is reset in reset_mkv_record and is always empty
			if(t <= maxt) System.out.printf("%f ",mkv.getPind()[0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getRepl()[0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getOpen()[0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getPreg()[0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getMilking()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getOpen()[0][t]+mkv.getPreg()[0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getMilksales()[t]); else System.out.printf("X ");
			//20
			if(t <= maxt) System.out.printf("%f ",mkv.getCwt()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getFeedcost()[0][t]+mkv.getFeedcost()[1][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getCullprice()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getCalfsales()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getCowsales()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getHeiferpurchasecost()[t]); else System.out.printf("X ");
			if(t <= Constants.LACT) System.out.printf("%f ",mkv.getCalvinginterval_clv()[t][0]); else System.out.printf("X "); 
			if(t <= Constants.SEA)  System.out.printf("%f ",mkv.getCalvinginterval_clv()[0][t]); else System.out.printf("X ");
			if(t <= Constants.LACT) System.out.printf("%f ",mkv.getDaystoconception_clv()[t][0]); else System.out.printf("X "); 
			if(t <= Constants.SEA)  System.out.printf("%f ",mkv.getDaystoconception_clv()[0][t]); else System.out.printf("X ");
			//30
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getDmi()[t][0]/Constants.STAGE*bio.getP_tmrdmlac()); else System.out.printf("X ");
			if(t <= Constants.SEA) System.out.printf("%f ",mkv.getRepl_clv()[sea][1]); else System.out.printf("X ");
			if(t <= Constants.CURR) System.out.printf("%f ",bio.getSmy()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getSmy()[t]); else System.out.printf("X ");
			if(t <= Constants.SEA) System.out.printf("%f ",mkv.getPind_clv()[sea][1]); else System.out.printf("X ");
			if(t <= Constants.CURR) System.out.printf("%f ",mkv.getDlbm()[t][0][0][0]); else System.out.printf("X ");
			if(t <= maxt && mkv.getEligible_serv()[0][t]+mkv.getEligible_keep()[0][t] > 0.0) System.out.printf("%f ",mkv.getEligible_keep()[0][t] / (mkv.getEligible_serv()[0][t]+mkv.getEligible_keep()[0][t])); else System.out.printf("X ");
			if(t <= maxt && mkv.getEligible_serv()[0][t] > 0.0)							 System.out.printf("%f ",mkv.getEligible_preg()[0][t] / mkv.getEligible_serv()[0][t]); else System.out.printf("X ");
			if(t <= maxt && mkv.getEligible_serv()[0][t]+mkv.getEligible_keep()[0][t] > 0.0) System.out.printf("%f ",mkv.getEligible_preg()[0][t] / (mkv.getEligible_serv()[0][t]+mkv.getEligible_keep()[0][t])); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getLact()[1][t]); else System.out.printf("X ");
			//40
			if(t <= maxt) System.out.printf("%f ",mkv.getLact()[2][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%d ",mkv.getEnter()[t]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getStatus()[t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getStatus()[t][1]); else System.out.printf("X ");
			if(t <= Constants.MIM && mkv.getStatus()[t][0] + mkv.getStatus()[t][1] > 0.0) System.out.printf("%f ",mkv.getStatus()[t][0] / (mkv.getStatus()[t][1] + mkv.getStatus()[t][0])); else System.out.printf("X ");
			if(t <= Constants.MIM && mkv.getStatus()[t][0] + mkv.getStatus()[t][1] > 0.0) System.out.printf("%f ",mkv.getStatus()[t][1] / (mkv.getStatus()[t][1] + mkv.getStatus()[t][0])); else System.out.printf("X ");			
			if(t <= maxt) System.out.printf("%f ",mkv.getCalved()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getFixedcost_labor()[t]+mkv.getFixedcost_other()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getCash()[t]-mkv.getFixedcost_labor()[t]-mkv.getFixedcost_other()[t]); else System.out.printf("X ");	//saldo
			if(t <= maxt && mkv.getMilking()[t] > 0.0) System.out.printf("%f ",mkv.getMilkyield()[0][t]/mkv.getMilking()[t]/Constants.STAGE); else System.out.printf("X ");
			//50
			if(t <= maxt) System.out.printf("%f ",mkv.getFeedcost()[1][t]/Constants.STAGE); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getInseminationvalue()[t][0][0]); else System.out.printf("X ");
			if(t <= maxt && mkv.getRpo_cnt()[t] > 0.0) System.out.printf("%f ",mkv.getRpo()[t] / mkv.getRpo_cnt()[t]); else System.out.printf("X ");
			if(t == 1) System.out.printf("%f ",mkv.getPind()[0][12]); else if(t <= maxt) System.out.printf("%f ",mkv.getPind()[0][t-1]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getRepl()[0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getInseminationvalue()[0][t][0]); else System.out.printf("X ");
			if(t <= Constants.CURR) System.out.printf("%f ",mkv.getDfs()[t][0][0][0]); else System.out.printf("X ");
			if(t <= Constants.CURR) System.out.printf("%f ",mkv.getDaystoconc()[t][0][0][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getHz_open()[t][1]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getHz_open()[t][2]); else System.out.printf("X ");
			//60
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getHz_preg()[t][1]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getHz_preg()[t][2]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getReplopen_mlk()[t][0][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getReplopen_mlk()[0][t][0]); else System.out.printf("X ");
			if(t <= Constants.CURR) System.out.printf("%f ",mkv.getDvwp()[t][0][0][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getDim_()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getTotrevenue()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getTotcost()[t]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getReplopen_dim()[t][0][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getReplopen_dim()[0][t][0]); else System.out.printf("X ");
			//70
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getReplopen_cur()[t][0][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getReplopen_cur()[0][t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getReplopen_rev()[t][0][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getReplopen_rev()[0][t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getReplopen_iof()[t][0][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getReplopen_iof()[0][t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getReplopen_rpo()[t][0][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getReplopen_rpo()[0][t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getDysopencost()[0][t][0]); else System.out.printf("X ");
			if(t <= maxt && bio.getP_tmrdmlac() > 0) System.out.printf("%f ",mkv.getFeedcost()[1][t]/Constants.STAGE/bio.getP_tmrdmlac()); else System.out.printf("X ");
			//80
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getDmi()[t][0]/Constants.STAGE); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getDyspregcost()[0][t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getMilkyield()[t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getMilkyield_cnt()[t][0]); else System.out.printf("X ");
			if(t <= Constants.LACT) System.out.printf("%f ",mkv.getLact()[t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getHz_cull()[t]); else System.out.printf("X ");
			if(t <= Constants.MIM) System.out.printf("%f ",mkv.getCulled()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getBreedingsupplycost()[t]); else System.out.printf("X ");
			try{
				if(t <= Constants.CURR) System.out.printf("%f ",mkv.getPv_curr()[t][0]); else if(t >= 30 && t < 30+Constants.CURR) System.out.printf("%f ",mkv.getPv_curr()[t-29][10]); else System.out.printf("X ");
			}catch(Exception e){
				e.printStackTrace();
				System.out.println("Exception 1 .. ");
				System.out.println("t: "+t +"   t-29: "+(t-29));
			}
			
			try{
				if(t <= Constants.LACT) System.out.printf("%f ",mkv.getPv_lact()[t][0]); else if(t >= 30 && t < 30+Constants.LACT) System.out.printf("%f ",mkv.getPv_lact()[t-29][10]); else System.out.printf("X ");
			}catch(Exception e){
				e.printStackTrace();
				System.out.println("Exception 2 .. ");
				System.out.println("t: "+t +"   t-29: "+(t-29));
			}
			
			//90
			try{
				if(t <= Constants.MIM) System.out.printf("%f ",mkv.getPv_mim()[t][0]); else if(t >= 30 && t < 30+Constants.MIM) System.out.printf("%f ",mkv.getPv_mim()[t-29][10]); else System.out.printf("X ");
			}catch(Exception e){
				e.printStackTrace();
				System.out.println("Exception 3 .. ");
				System.out.println("t: "+t +"   t-29: "+(t-29));
			}
			
			if(t <= Constants.MPREG+2) System.out.printf("%f ",mkv.getPv_mpreg()[t-1]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getPv_t()[t][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getPv_t()[t][10]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getLabortime()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getLaborcost()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getClvinterval()[0][0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getDaystoconc()[0][0][0][t]); else System.out.printf("X ");
			switch(t)
			{	//					mkv.getPv_curr_lact()[curr][lact][mpreg]

				case 1: System.out.printf("%f ",mkv.getPv_curr_lact()[2][1][1]); break;
				case 2: System.out.printf("%f ",mkv.getPv_curr_lact()[2][1][4]); break;
				case 3: System.out.printf("%f ",mkv.getPv_curr_lact()[2][1][7]); break;
				case 4: System.out.printf("%f ",mkv.getPv_curr_lact()[2][2][1]); break;
				case 5: System.out.printf("%f ",mkv.getPv_curr_lact()[2][2][4]); break;
				case 6: System.out.printf("%f ",mkv.getPv_curr_lact()[2][2][7]); break;
				case 7: System.out.printf("%f ",mkv.getPv_curr_lact()[2][3][1]); break;
				case 8: System.out.printf("%f ",mkv.getPv_curr_lact()[2][3][4]); break;
				case 9: System.out.printf("%f ",mkv.getPv_curr_lact()[2][3][7]); break;

				case 10: System.out.printf("%f ",mkv.getPv_curr_lact()[8][1][1]); break;
				case 11: System.out.printf("%f ",mkv.getPv_curr_lact()[8][1][4]); break;
				case 12: System.out.printf("%f ",mkv.getPv_curr_lact()[8][1][7]); break;
				case 13: System.out.printf("%f ",mkv.getPv_curr_lact()[8][2][1]); break;
				case 14: System.out.printf("%f ",mkv.getPv_curr_lact()[8][2][4]); break;
				case 15: System.out.printf("%f ",mkv.getPv_curr_lact()[8][2][7]); break;
				case 16: System.out.printf("%f ",mkv.getPv_curr_lact()[8][3][1]); break;
				case 17: System.out.printf("%f ",mkv.getPv_curr_lact()[8][3][4]); break;
				case 18: System.out.printf("%f ",mkv.getPv_curr_lact()[8][3][7]); break;
				
				case 19: System.out.printf("%f ",mkv.getPv_curr_lact()[14][1][1]); break;
				case 20: System.out.printf("%f ",mkv.getPv_curr_lact()[14][1][4]); break;
				case 21: System.out.printf("%f ",mkv.getPv_curr_lact()[14][1][7]); break;
				case 22: System.out.printf("%f ",mkv.getPv_curr_lact()[14][2][1]); break;
				case 23: System.out.printf("%f ",mkv.getPv_curr_lact()[14][2][4]); break;
				case 24: System.out.printf("%f ",mkv.getPv_curr_lact()[14][2][7]); break;
				case 25: System.out.printf("%f ",mkv.getPv_curr_lact()[14][3][1]); break;
				case 26: System.out.printf("%f ",mkv.getPv_curr_lact()[14][3][4]); break;
				case 27: System.out.printf("%f ",mkv.getPv_curr_lact()[14][3][7]); break;
				default: System.out.printf("X "); break;
			}
			if(t <= 2*Constants.SEA) System.out.printf("%f ",mkv.getOpportunitycost()[t]); else if(t <= 3*Constants.SEA) System.out.printf("%f ",mkv.getOpportunitycost()[t-Constants.SEA]); else System.out.printf("X ");
			//100
			if(t <= maxt && mkv.getValue_cnt()[t] > 0) System.out.printf("%f ",mkv.getValue()[t]/mkv.getValue_cnt()[t]*mkv.getPresent()[0][t]); else System.out.printf("X ");
			if(t <= Constants.CURR) System.out.printf("%f ",mkv.getPind_rpo()[t][0][0][0]); else System.out.printf("X ");
			if(t <= Constants.LACT) System.out.printf("%f ",mkv.getPind_rpo()[0][t][0][0]); else System.out.printf("X ");
			if(t <= Constants.MIM)  System.out.printf("%f ",mkv.getPind_rpo()[0][0][t][0]); else System.out.printf("X ");
			if(t <= Constants.MPREG+1) System.out.printf("%f ",mkv.getPind_rpo()[0][0][0][t-1]); else System.out.printf("X ");
			if(t <= Constants.LACT) System.out.printf("%f ",mkv.getDaysvwp_clv()[t][0]); else System.out.printf("X "); 
			if(t <= Constants.SEA)  System.out.printf("%f ",mkv.getDaysvwp_clv()[0][t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getDvwp()[0][0][0][t]); else System.out.printf("X ");
			if(t <= Constants.LACT) System.out.printf("%f ",mkv.getDaysfs_clv()[t][0]); else System.out.printf("X "); 
			if(t <= Constants.SEA)  System.out.printf("%f ",mkv.getDaysfs_clv()[0][t]); else System.out.printf("X ");
			//110
			if(t <= maxt) System.out.printf("%f ",mkv.getDfs()[0][0][0][t]); else System.out.printf("X ");
			if(t <= Constants.LACT) System.out.printf("%f ",mkv.getDayslbm_clv()[t][0]); else System.out.printf("X "); 
			System.out.printf("X "); //if(t <= Constants.SEA) System.out.printf("%f ",mkv.getdayslbm_clv[0][t]); else System.out.printf("X "); //not calculated
			if(t <= maxt) System.out.printf("%f ",mkv.getDlbm()[0][0][0][t]); else System.out.printf("X ");
			if(t <= Constants.MIM)  System.out.printf("%f ",mkv.getStatus()[t][0]+mkv.getStatus()[t][1]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getBreedings1()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getDryoffyield()[t]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getEligible_bred()[0][t]); else System.out.printf("X ");
			if(t <= Constants.MIM)  System.out.printf("%f ",mkv.getEligible_keep()[t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM)  System.out.printf("%f ",mkv.getEligible_serv()[t][0]); else System.out.printf("X ");
			//120
			if(t <= Constants.MIM)  System.out.printf("%f ",mkv.getEligible_bred()[t][0]); else System.out.printf("X ");
			if(t <= Constants.MIM)  System.out.printf("%f ",mkv.getEligible_preg()[t][0]); else System.out.printf("X ");
			if(t <= maxt) System.out.printf("%f ",mkv.getKeep_rev0()[t]); else System.out.printf("X ");
			
			if(t <= Constants.MIM)		System.out.printf("%d ",t);
			else if(t <= Constants.MIM*2) System.out.printf("%d ",t-Constants.MIM);
			else if(t <= Constants.MIM*3) System.out.printf("%d ",t-Constants.MIM*2);
			else System.out.printf("X ");

			if(t <= Constants.MIM)		System.out.printf("%.2f ",rpo.getCow()[8][1][t][0][bio.getStart_sea()]);
			else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",rpo.getCow()[8][2][t-Constants.MIM][0][bio.getStart_sea()]);
			else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",rpo.getCow()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]);
			else System.out.printf("X ");

			if(t <= Constants.MIM)		System.out.printf("%.2f ",bio.getIofc()[8][1][t][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",bio.getIofc()[8][2][t-Constants.MIM][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",bio.getIofc()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]/Constants.STAGE);
			else System.out.printf("X ");

			if(t <= Constants.MIM)		System.out.printf("%.2f ",bio.getRev()[8][1][t][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",bio.getRev()[8][2][t-Constants.MIM][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",bio.getRev()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]/Constants.STAGE);
			else System.out.printf("X ");

			if(t <= Constants.MIM)		System.out.printf("%.2f ",bio.getMilkyield()[8][1][t][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",bio.getMilkyield()[8][2][t-Constants.MIM][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",bio.getMilkyield()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]/Constants.STAGE);
			else System.out.printf("X ");

			if(t <= Constants.MIM)		System.out.printf("%.2f ",rpo.getPrg()[8][1][t][0][bio.getStart_sea()]);
			else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",rpo.getPrg()[8][2][t-Constants.MIM][0][bio.getStart_sea()]);
			else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",rpo.getPrg()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]);
			else System.out.printf("X ");
			
			if(bio.getDmi()[8][1][1][0][bio.getStart_sea()] > 0.0)
			{
				if(t <= Constants.MIM)		System.out.printf("%.2f ",bio.getMilkyield()[8][1][t][0][bio.getStart_sea()]/bio.getDmi()[8][1][t][0][bio.getStart_sea()]);
				else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",bio.getMilkyield()[8][2][t-Constants.MIM][0][bio.getStart_sea()]/bio.getDmi()[8][2][t-Constants.MIM][0][bio.getStart_sea()]);
				else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",bio.getMilkyield()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]/bio.getDmi()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]);
				else System.out.printf("X ");
			}
			//130
			if(t <= Constants.MIM)		System.out.printf("%.2f ",bio.getDmi()[8][1][t][0][bio.getStart_sea()]*bio.getP_tmrdmlac()/Constants.STAGE);
			else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",bio.getDmi()[8][2][t-Constants.MIM][0][bio.getStart_sea()]*bio.getP_tmrdmlac()/Constants.STAGE);
			else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",bio.getDmi()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]*bio.getP_tmrdmlac()/Constants.STAGE);
			else System.out.printf("X ");

			if(t <= Constants.MIM)		System.out.printf("%.2f ",bio.getVarcost()[8][1][t][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*2)	System.out.printf("%.2f ",bio.getVarcost()[8][2][t-Constants.MIM][0][bio.getStart_sea()]/Constants.STAGE);
			else if(t <= Constants.MIM*3)	System.out.printf("%.2f ",bio.getVarcost()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]/Constants.STAGE);
			else System.out.printf("X ");

			if(t <= Constants.MIM)		System.out.printf("%d ",pol.getCow()[8][1][t][0][bio.getStart_sea()]);
			else if(t <= Constants.MIM*2)	System.out.printf("%d ",pol.getCow()[8][2][t-Constants.MIM][0][bio.getStart_sea()]);
			else if(t <= Constants.MIM*3)	System.out.printf("%d ",pol.getCow()[8][3][t-Constants.MIM*2][0][bio.getStart_sea()]);
			else System.out.printf("X ");

			if(t <= Constants.SEA*2)	System.out.printf("%.2f ",bio.getP_milk()[t]); else System.out.printf("X ");
			if(t <= Constants.SEA*2)	System.out.printf("%.2f ",bio.getP_heifer()[t]); else System.out.printf("X ");



		//	if(t == 1) System.out.printf("%f ",mkv.getpv_mim[9][4]); //dim = 152
		//	else if(t == 2) System.out.printf("%f ",mkv.getpv_mim[9][7]); //dim = 152
		//	else if(t == 3) System.out.printf("%f ",mkv.getpv_mim[15][4]); //dim = 526
		//	else if(t == 4) System.out.printf("%f ",mkv.getpv_mim[15][7]); //dim = 426
		//	else System.out.printf("0 ");

		//	if(t > 1 && mkv.getclvintervalcnt[t] > 0) System.out.printf("%f ",mkv.getclvinterval[t]/mkv.getclvintervalcnt[t]); else System.out.printf("0 "); 
		//	System.out.printf("%f ",mkv.getcalved_clv[sea][1]);
		//	System.out.printf("%f ",mkv.getcalved_clv[sea][1]);
		//	if(t <= Constants.SEA) if(mkv.getpregnancyrate0[sea][1] > 0.0) System.out.printf("%f ",mkv.getpregnancyrate0[sea][1]); else System.out.printf("0 ");
		//	if(t <= Constants.SEA) if(mkv.getpregnancyrate1[sea][1] > 0.0) System.out.printf("%f ",mkv.getpregnancyrate1[sea][1]); else System.out.printf("0 ");

			sea++; if(sea > Constants.SEA) sea = 1;		//season in next stage
		}

		System.out.printf("\n%f %f %f herdlife         ",mkv.getHerdlife()[1],mkv.getHerdlife()[2],mkv.getHerdlife()[3]);
		System.out.printf("\n%f %f %f eaa_cyr          ",mkv.getEaa_cyr()[1],mkv.getEaa_cyr()[2],mkv.getEaa_cyr()[3]);
		System.out.printf("\n%f %f %f eaa_cwt          ",mkv.getEaa_cwt()[1],mkv.getEaa_cwt()[2],mkv.getEaa_cwt()[3]);
		System.out.printf("\n%f %f %f cash_cyr         ",mkv.getCash_cyr()[1],mkv.getCash_cyr()[2],mkv.getCash_cyr()[3]);
		System.out.printf("\n%f %f %f milkyield_cyr    ",mkv.getMilkyield_cyr()[1],mkv.getMilkyield_cyr()[2],mkv.getMilkyield_cyr()[3]);	
		System.out.printf("\n%f %f %f milkyield_cwt    ",mkv.getMilkyield_cwt()[1],mkv.getMilkyield_cwt()[2],mkv.getMilkyield_cwt()[3]);
		System.out.printf("\n%f %f %f milksales_cyr    ",mkv.getMilksales_cyr()[1],mkv.getMilksales_cyr()[2],mkv.getMilksales_cyr()[3]);	
		System.out.printf("\n%f %f %f milksales_cwt    ",mkv.getMilksales_cwt()[1],mkv.getMilksales_cwt()[2],mkv.getMilksales_cwt()[3]);	
		System.out.printf("\n%f %f %f feedcost_cyr     ",mkv.getFeedcost_cyr()[1],mkv.getFeedcost_cyr()[2],mkv.getFeedcost_cyr()[3]);
		System.out.printf("\n%f %f %f feedcost_cwt     ",mkv.getFeedcost_cwt()[1],mkv.getFeedcost_cwt()[2],mkv.getFeedcost_cwt()[3]);
		System.out.printf("\n%f %f %f heifercost_cyr   ",mkv.getHeifercost_cyr()[1],mkv.getHeifercost_cyr()[2],mkv.getHeifercost_cyr()[3]);
		System.out.printf("\n%f %f %f heifercost_cwt   ",mkv.getHeifercost_cwt()[1],mkv.getHeifercost_cwt()[2],mkv.getHeifercost_cwt()[3]);
		System.out.printf("\n%f %f %f cowsales_cyr     ",mkv.getCowsales_cyr()[1],mkv.getCowsales_cyr()[2],mkv.getCowsales_cyr()[3]);
		System.out.printf("\n%f %f %f cowsales_cwt     ",mkv.getCowsales_cwt()[1],mkv.getCowsales_cwt()[2],mkv.getCowsales_cwt()[3]);
		System.out.printf("\n%f %f %f calfsales_cyr    ",mkv.getCalfsales_cyr()[1],mkv.getCalfsales_cyr()[2],mkv.getCalfsales_cyr()[3]);
		System.out.printf("\n%f %f %f calfsales_cwt    ",mkv.getCalfsales_cwt()[1],mkv.getCalfsales_cwt()[2],mkv.getCalfsales_cwt()[3]);
		System.out.printf("\n%f %f %f livestockcost_cyr",mkv.getLivestockcost_cyr()[1],mkv.getLivestockcost_cyr()[2],mkv.getLivestockcost_cyr()[3]);
		System.out.printf("\n%f %f %f livestockcost_cwt",mkv.getLivestockcost_cwt()[1],mkv.getLivestockcost_cwt()[2],mkv.getLivestockcost_cwt()[3]);
		System.out.printf("\n%f %f %f clvinterval      ",mkv.getClvinterval()[0][1][0],mkv.getClvinterval()[0][2][0],mkv.getClvinterval()[0][3][0]);
		System.out.printf("\n%f %f %f daystoconc       ",mkv.getDaystoconc()[0][0][1][0],mkv.getDaystoconc()[0][0][2][0],mkv.getDaystoconc()[0][0][3][0]);
		System.out.printf("\n%f %f %f cullrateall      ",mkv.getCullrateall()[1],mkv.getCullrateall()[2],mkv.getCullrateall()[3]);
		System.out.printf("\n%f %f %f cullratevol      ",mkv.getCullratevol()[1],mkv.getCullratevol()[2],mkv.getCullratevol()[3]);
		System.out.printf("\n%f %f %f cullrateinv      ",mkv.getCullrateinv()[1],mkv.getCullrateinv()[2],mkv.getCullrateinv()[3]);
		System.out.printf("\n%f %f %f laborcost_cyr    ",mkv.getLaborcost_cyr()[1],mkv.getLaborcost_cyr()[2],mkv.getLaborcost_cyr()[3]);
		System.out.printf("\n%f %f %f laborcost_cwt    ",mkv.getLaborcost_cwt()[1],mkv.getLaborcost_cwt()[2],mkv.getLaborcost_cwt()[3]);
		System.out.printf("\n%f %f %f vetcost_cyr      ",mkv.getVetcost_cyr()[1],mkv.getVetcost_cyr()[2],mkv.getVetcost_cyr()[3]);
		System.out.printf("\n%f %f %f vetcost_cwt      ",mkv.getVetcost_cwt()[1],mkv.getVetcost_cwt()[2],mkv.getVetcost_cwt()[3]);
		System.out.printf("\n%f %f %f breedingsupplycost_cyr ",mkv.getBreedingsupplycost_cyr()[1],mkv.getBreedingsupplycost_cyr()[2],mkv.getBreedingsupplycost_cyr()[3]);
		System.out.printf("\n%f %f %f breedingsupplycost_cwt ",mkv.getBreedingsupplycost_cwt()[1],mkv.getBreedingsupplycost_cwt()[2],mkv.getBreedingsupplycost_cwt()[3]);
		System.out.printf("\n%f %f %f loss_cyr         ",mkv.getLoss_cyr()[1],mkv.getLoss_cyr()[2],mkv.getLoss_cyr()[3]);
		System.out.printf("\n%f %f %f loss_cwt         ",mkv.getLoss_cwt()[1],mkv.getLoss_cwt()[2],mkv.getLoss_cwt()[3]);
		System.out.printf("\n%f %f %f othercost_cyr    ",mkv.getOthercost_cyr()[1],mkv.getOthercost_cyr()[2],mkv.getOthercost_cyr()[3]);
		System.out.printf("\n%f %f %f othercost_cwt    ",mkv.getOthercost_cwt()[1],mkv.getOthercost_cwt()[2],mkv.getOthercost_cwt()[3]);
		System.out.printf("\n%f %f %f pregnancyrate0   ",mkv.getPregnancyrate0()[0][1],mkv.getPregnancyrate0()[0][2],mkv.getPregnancyrate0()[0][3]);
		System.out.printf("\n%f %f %f pregnancyrate1   ",mkv.getPregnancyrate1()[0][1],mkv.getPregnancyrate0()[0][2],mkv.getPregnancyrate0()[0][3]);
		System.out.printf("\n%f %f %f daysopen         ",mkv.getDaysopen()[0][1],mkv.getDaysopen()[0][2],mkv.getDaysopen()[0][3]);
		System.out.printf("\n%f %f %f fixedcost_labor_cyr ",mkv.getFixedcost_labor_cyr()[1],mkv.getFixedcost_labor_cyr()[2],mkv.getFixedcost_labor_cyr()[3]);
		System.out.printf("\n%f %f %f fixedcost_labor_cwt ",mkv.getFixedcost_labor_cwt()[1],mkv.getFixedcost_labor_cwt()[2],mkv.getFixedcost_labor_cwt()[3]);
		System.out.printf("\n%f %f %f fixedcost_other_cyr ",mkv.getFixedcost_other_cyr()[1],mkv.getFixedcost_other_cyr()[2],mkv.getFixedcost_other_cyr()[3]);
		System.out.printf("\n%f %f %f fixedcost_other_cwt ",mkv.getFixedcost_other_cwt()[1],mkv.getFixedcost_other_cwt()[2],mkv.getFixedcost_other_cwt()[3]);
		System.out.printf("\n%f %f %f preglaborcost     ",mkv.getPreglaborcost()[1],mkv.getPreglaborcost()[2],mkv.getPreglaborcost()[3]);
		System.out.printf("\n%f %f %f pregsupplycost    ",mkv.getPregsupplycost()[1],mkv.getPregsupplycost()[2],mkv.getPregsupplycost()[3]);
		System.out.printf("\n%f %f %f breedingcost_cyr  ",mkv.getBreedingcost_cyr()[1],mkv.getBreedingcost_cyr()[2],mkv.getBreedingcost_cyr()[3]);
		System.out.printf("\n%f %f %f breedingcost_cwt  ",mkv.getBreedingcost_cwt()[1],mkv.getBreedingcost_cwt()[2],mkv.getBreedingcost_cwt()[3]);
		System.out.printf("\n%f %f %f pv_open           ",mkv.getPv_open()[1],mkv.getPv_open()[2],mkv.getPv_open()[3]);
		System.out.printf("\n%f %f %f inseminationvalue ",mkv.getInseminationvalue()[0][0][1],mkv.getInseminationvalue()[0][0][2],mkv.getInseminationvalue()[0][0][3]);
		System.out.printf("\n%f %f %f opendays          ",mkv.getOpendays()[1],mkv.getOpendays()[2],mkv.getOpendays()[3]);
		System.out.printf("\n%f %f %f abortrisk         ",mkv.getAbortrisk()[1],mkv.getAbortrisk()[2],mkv.getAbortrisk()[3]);
		System.out.printf("\n%f %f %f pv_preg           ",mkv.getPv_preg()[1],mkv.getPv_preg()[2],mkv.getPv_preg()[3]);
		System.out.printf("\n%f %f %f feedcostdry_cyr   ",mkv.getFeedcostdry_cyr()[1],mkv.getFeedcostdry_cyr()[2],mkv.getFeedcostdry_cyr()[3]);
		System.out.printf("\n%f %f %f feedcostlac_cyr   ",mkv.getFeedcostlac_cyr()[1],mkv.getFeedcostlac_cyr()[2],mkv.getFeedcostlac_cyr()[3]);
		System.out.printf("\n%f %f %f cowvalue          ",mkv.getCowvalue()[1],mkv.getCowvalue()[2],mkv.getCowvalue()[3]);
		System.out.printf("\n%f %f %f dim               ",mkv.getDimy()[1],mkv.getDimy()[2],mkv.getDimy()[3]);
		System.out.printf("\n%f %f %f daysfs            ",mkv.getDfs()[0][0][1][0],mkv.getDfs()[0][0][2][0],mkv.getDfs()[0][0][3][0]);
		System.out.printf("\n%f %f %f cullprice y       ",mkv.getCullpricey()[1],mkv.getCullpricey()[2],mkv.getCullpricey()[3]);
		System.out.printf("\n%f %f %f replopen_mlk      ",mkv.getReplopen_mlk()[0][0][1],mkv.getReplopen_mlk()[0][0][2],mkv.getReplopen_mlk()[0][0][3]);
		System.out.printf("\n%f %f %f replopen_cur      ",mkv.getReplopen_cur()[0][0][1],mkv.getReplopen_cur()[0][0][2],mkv.getReplopen_cur()[0][0][3]);
		System.out.printf("\n%f %f %f replopen_rev      ",mkv.getReplopen_rev()[0][0][1],mkv.getReplopen_rev()[0][0][2],mkv.getReplopen_rev()[0][0][3]);
		System.out.printf("\n%f %f %f replopen_iof      ",mkv.getReplopen_iof()[0][0][1],mkv.getReplopen_iof()[0][0][2],mkv.getReplopen_iof()[0][0][3]);
		System.out.printf("\n%f %f %f replopen_rpo      ",mkv.getReplopen_rpo()[0][0][1],mkv.getReplopen_rpo()[0][0][2],mkv.getReplopen_rpo()[0][0][3]);
		System.out.printf("\n%f %f %f replopen_dim      ",mkv.getReplopen_dim()[0][0][1],mkv.getReplopen_dim()[0][0][2],mkv.getReplopen_dim()[0][0][3]);
//&
		System.out.printf("\n%f %f %f dvwp              ",mkv.getDvwp()[0][0][1][0],mkv.getDvwp()[0][0][2][0],mkv.getDvwp()[0][0][3][0]);
		System.out.printf("\n%f %f %f dlbm              ",mkv.getDlbm()[0][0][1][0],mkv.getDlbm()[0][0][2][0],mkv.getDlbm()[0][0][3][0]);
		System.out.printf("\n%f %f %f daysopen_cost     ",mkv.getDaysopen_cost()[1],mkv.getDaysopen_cost()[2],mkv.getDaysopen_cost()[3]);
		System.out.printf("\n%f %f %f dayspreg_cost     ",mkv.getDayspreg_cost()[1],mkv.getDayspreg_cost()[2],mkv.getDayspreg_cost()[3]);

		
		
		
		
		
		
		
		
		
		
		
	}
	
	
	
	
	
	
	
	
	
	public static void writePolFile(PolRecord pol){
		int	sea = 0, curr = 0, lact = 0, mim = 0, mpreg = 0;
		System.out.printf("\n WRITE_POL_FILE started ...");
		for(sea = 1; sea <= 2*Constants.SEA; sea++)
			System.out.printf(" %d",pol.getEnter()[sea]);
		for(sea = 1; sea <= 2*Constants.SEA; sea++)
		{
			for(curr = 1; curr <= Constants.CURR; curr++)
				for(lact = 1; lact <= Constants.LACT; lact++)
					for(mpreg = 0; mpreg <= Constants.MPREG; mpreg++) 
					{
						System.out.printf("\n%2d %2d %2d %2d",sea,curr,lact,mpreg);
						for(mim = 1; mim <= Constants.MIM; mim++)
						{
							System.out.printf(" %d",pol.getCow()[curr][lact][mim][mpreg][sea]);
						}
					}
			if((int)sea % (int)((double)(2*Constants.SEA) / 12) == 0 || sea == 1)
				System.out.printf(" %.0f%%",(double)sea/(2*Constants.SEA)*100);
		}
		System.out.printf("\n WRITE_POL_FILE done ...");
	}
	
	
	
	public static void writeRpoFile(BioRecord bio, RpoRecord rpo, InsRecord ins){
		int	curr = 0, lact = 0, mim = 0, mpreg = 0, sea = 0;
		System.out.printf("\n WRITE_RPO_FILE started ...");
		
		for(sea = 1; sea <= Constants.SEA; sea++)
		{
			for(curr = 1; curr <= Constants.CURR; curr++)
				for(lact = 1; lact <= Constants.LACT; lact++)
					for(mim = 1; mim <= Constants.MIM; mim++)
						for(mpreg = 0; mpreg <= Constants.MPREG; mpreg++) if(mpreg == 0 || (mim - mpreg >= 2 && mim - mpreg <= 15))
						{
							System.out.printf("%2d %2d %2d %2d %2d",curr,lact,mim,mpreg,sea);
							System.out.printf(" %4.0f",rpo.getCow()[curr][lact][mim][mpreg][sea]);
							System.out.printf(" %4.0f",rpo.getCow()[curr][lact][mim][mpreg][sea+12]);
							if(mpreg == 0)
							{
								System.out.printf(" %4.0f",ins.getCow()[curr][lact][mim][sea]);			
								System.out.printf(" %4.0f",ins.getCow()[curr][lact][mim][sea+12]);
							}
							else
							{
								System.out.printf("    0");
								System.out.printf("    0");
							}
							System.out.printf(" %4.0f",rpo.getPrg()[curr][lact][mim][mpreg][sea]);
							System.out.printf(" %4.0f",rpo.getPrg()[curr][lact][mim][mpreg][sea+12]);

							System.out.printf(" %4.0f",bio.getSel()[lact][mim][sea]);
							System.out.printf(" %5.2f",bio.getMilkyield()[curr][lact][mim][mpreg][sea] / Constants.STAGE);
							System.out.printf(" %5.2f",bio.getMilkyield()[8][lact][mim][mpreg][sea] / Constants.STAGE);

							System.out.printf(" 0");	
							System.out.printf(" 0");	

							System.out.printf("\n");

						}
			System.out.printf(" %.0f%%",(double)sea/Constants.SEA*100);
		}
		System.out.printf("\n WRITE_RPO_FILE done ...");
	}
	
	
	public static void writeBioFile(BioRecord bio){
		/*System.out.println("bio.getUnit(): "+bio.getUnit());
		System.out.println("bio.getAnalysis(): "+bio.getAnalysis());
		
		for(int i=1; i<=9; i++){
			System.out.printf("bio.getMilk_mpreg()["+i+"]"+bio.getMilk_mpreg()[i]+"\t");
		}
		System.out.println("");*/
		

		
		/**for(int lact = 1; lact <= Constants.LACT; lact++)
			for(int mim = 1; mim <= Constants.MIM; mim++)
				for(int mpreg = 0; mpreg <= Constants.MPREG; mpreg++)
					for(int sea = 1; sea <= Constants.SEA; sea++){
						for(int curr = 1; curr <= Constants.CURR; curr++)
							System.out.printf("bio.getMilkyield()["+curr+"]["+lact+"]["+mim+"]["+mpreg+"]["+sea+"]: "+bio.getMilkyield()[curr][lact][mim][mpreg][sea]+"  ");
						
						System.out.println("");
					}*/	
		
		
			/*for(int sea = 1; sea <= Constants.SEA; sea++){
				for(int curr = 1; curr <= Constants.CURR; curr++)
					System.out.printf("bio.getMilkyield()["+curr+"]["+Constants.LACT/2+"]["+Constants.MIM/2+"]["+Constants.MPREG/2+"]["+sea+"]: "+bio.getMilkyield()[curr][Constants.LACT/2][Constants.MIM/2][Constants.MPREG/2][sea]+"  ");
				
				System.out.println("");
			}*/
		
		
		/**for(int lact = 1; lact <= Constants.LACT; lact++)
			for(int mim = 1; mim <= Constants.MIM; mim++)
				for(int sea = 1; sea <= Constants.SEA; sea++)
					System.out.println("bio.getPind()["+lact+"]["+mim+"]["+sea+"]: "+bio.getPind()[lact][mim][sea]);
		*/
		
		/*for(int mim = 1; mim <= Constants.MIM; mim++)
			for(int sea = 1; sea <= Constants.SEA; sea++)
				System.out.println("bio.getPind()["+Constants.LACT/2+"]["+mim+"]["+sea+"]: "+bio.getPind()[Constants.LACT/2][mim][sea]);
		*/
	
		/*
		for(int i=2; i<=9; i++){
			System.out.printf("bio.getAbort()["+i+"]"+bio.getAbort()[i]+"\t");
		}
		System.out.println("");
		
		
		for(int i=1; i<=3; i++){
			System.out.printf("bio.getVwp()["+i+"]"+bio.getVwp()[i]+"\t");
		}
		System.out.println("");
		
		
		System.out.println("bio.getLbm(): "+bio.getLbm());
		System.out.println("bio.getTimebreeding(): "+bio.getTimebreeding());
		System.out.println("bio.getP_semen(): "+bio.getP_semen());
		System.out.println("bio.getMaxlact(): "+bio.getMaxlact());
		*/
		
		/**for(int lact = 1; lact <= Constants.LACT; lact++)
			for(int mim = 1; mim <= Constants.MIM; mim++)
				for(int sea = 1; sea <= Constants.SEA; sea++)
					System.out.println("bio.getConceptionrate()["+lact+"]["+mim+"]["+sea+"]: "+bio.getConceptionrate()[lact][mim][sea]);
		*/
		
		/*for(int mim = 1; mim <= Constants.MIM; mim++){
			for(int sea = 1; sea <= Constants.SEA; sea++){
				System.out.printf("bio.getConceptionrate()["+Constants.LACT/2+"]["+mim+"]["+sea+"]: %.4f",bio.getConceptionrate()[Constants.LACT/2][mim][sea]);
				System.out.printf("  ");
			}
			System.out.println("");
		}
			
		for(int mim = 1; mim <= Constants.MIM; mim++){
			for(int sea = 1; sea <= Constants.SEA; sea++){
				System.out.printf("bio.getHeatdetectionrate()["+mim+"]["+sea+"]: %.4f",bio.getHeatdetectionrate()[mim][sea]);
				System.out.printf("  ");
			}
			System.out.println("");
		}*/
	
		
		
		/*for(int mim = 1; mim <= Constants.MIM; mim++){
			for(int sea = 1; sea <= Constants.SEA; sea++){
				System.out.printf("bio.getReprocost()["+mim+"]["+sea+"]: %.4f",bio.getReprocost()[mim][sea]);
				System.out.printf("  ");
			}
			System.out.println("");	
		}*/
			
	
		/*	
		for(int mim = 1; mim <= Constants.MIM; mim++){
			for(int mpreg = 1; mpreg <= Constants.MPREG; mpreg++){
				System.out.printf("bio.getBw()["+Constants.LACT/2+"]["+mim+"]["+mpreg+"]: %.4f",bio.getBw()[Constants.LACT/2][mim][mpreg]);
				System.out.printf("  ");
			}
			System.out.println("");
		}
		
		for(int i = 1; i <= 3; i++){
			for(int mpreg = 1; mpreg <= Constants.MPREG; mpreg++){
				System.out.printf("bio.getBwpreg()["+i+"]["+mpreg+"]: %.4f",bio.getReprocost()[i][mpreg]);
				System.out.printf("  ");
			}
			System.out.println("");	
		}
		*/
		/**
		for(int lact = 1; lact <= Constants.LACT; lact++)
			for(int mim = 1; mim <= Constants.MIM; mim++)
				for(int mpreg = 1; mpreg <= Constants.MPREG; mpreg++)
					System.out.println("bio.getBw()["+lact+"]["+mim+"]["+mpreg+"]: "+bio.getBw()[lact][mim][mpreg]);
		
		for(int i = 1; i <= 3; i++)
			for(int mpreg = 1; mpreg <= Constants.MPREG; mpreg++)
				System.out.println("bio.getBwpreg()["+i+"]["+mpreg+"]: "+bio.getBwpreg()[i][mpreg]);
		*/
		
		
		/*
		for(int sea = 1; sea <= 2 * Constants.SEA; sea++)
			System.out.println("bio.getServe()["+sea+"]: "+bio.getServe()[sea]);
		
		for(int sea = 1; sea <= 2 * Constants.SEA; sea++)
			System.out.println("bio.getEnter()["+sea+"]: "+bio.getEnter()[sea]);
		*/
		
		/*for(int sea = 1; sea <= 2 * Constants.SEA; sea++)
			System.out.println("bio.getP_heifer()["+sea+"]: "+bio.getP_heifer()[sea]);
		for(int sea = 1; sea <= 2 * Constants.SEA; sea++)
			System.out.println("bio.getP_milk()["+sea+"]: "+bio.getP_milk()[sea]);
		for(int sea = 1; sea <= 2 * Constants.SEA; sea++)
			System.out.println("bio.getP_bodyweight()["+sea+"]: "+bio.getP_bodyweight()[sea]);
		*/
		
		/**
		p_heifer[1] = 2100; 	p_heifer[2] = 2100; 	p_heifer[3] = 2100; 	p_heifer[4] = 2100; 	p_heifer[5] = 2100; 	p_heifer[6] = 2100; 	p_heifer[7] = 2100; 	p_heifer[8] = 2100; 	p_heifer[9] = 2100; 	p_heifer[10] = 2100; 	p_heifer[11] = 2100; 	p_heifer[12] = 2100; 	p_heifer[13] = 2100; 	p_heifer[14] = 2100; 	p_heifer[15] = 2100; 	p_heifer[16] = 2100; 	p_heifer[17] = 2100; 	p_heifer[18] = 2100; 	p_heifer[19] = 2100; 	p_heifer[20] = 2100; 	p_heifer[21] = 2100; 	p_heifer[22] = 2100; 	p_heifer[23] = 2100; 	p_heifer[24] = 2100; 
		p_milk[1] = 35; 	p_milk[2] = 35; 	p_milk[3] = 35; 	p_milk[4] = 35; 	p_milk[5] = 35; 	p_milk[6] = 35; 	p_milk[7] = 35; 	p_milk[8] = 35; 	p_milk[9] = 35; 	p_milk[10] = 35; 	p_milk[11] = 35; 	p_milk[12] = 35; 	p_milk[13] = 35; 	p_milk[14] = 35; 	p_milk[15] = 35; 	p_milk[16] = 35; 	p_milk[17] = 35; 	p_milk[18] = 35; 	p_milk[19] = 35; 	p_milk[20] = 35; 	p_milk[21] = 35; 	p_milk[22] = 35; 	p_milk[23] = 35; 	p_milk[24] = 35; 
		p_bodyweight[1] = 0.8; 	p_bodyweight[2] = 0.8; 	p_bodyweight[3] = 0.8; 	p_bodyweight[4] = 0.8; 	p_bodyweight[5] = 0.8; 	p_bodyweight[6] = 0.8; 	p_bodyweight[7] = 0.8; 	p_bodyweight[8] = 0.8; 	p_bodyweight[9] = 0.8; 	p_bodyweight[10] = 0.8; 	p_bodyweight[11] = 0.8; 	p_bodyweight[12] = 0.8; 	p_bodyweight[13] = 0.8; 	p_bodyweight[14] = 0.8; 	p_bodyweight[15] = 0.8; 	p_bodyweight[16] = 0.8; 	p_bodyweight[17] = 0.8; 	p_bodyweight[18] = 0.8; 	p_bodyweight[19] = 0.8; 	p_bodyweight[20] = 0.8; 	p_bodyweight[21] = 0.8; 	p_bodyweight[22] = 0.8; 	p_bodyweight[23] = 0.8; 	p_bodyweight[24] = 0.8; 
		*/	
		
		System.out.println("bio.getWritepol(): "+bio.getWritepol());
		System.out.println("bio.getWriterpo(): "+bio.getWriterpo());
		System.out.println("bio.getStart_sea(): "+bio.getStart_sea());
		System.out.println("bio.getPolicy(): "+bio.getPolicy());
		System.out.println("bio.getMaxmim(): "+bio.getMaxmim());
		System.out.println("bio.getCullmilk(): "+bio.getCullmilk());
		System.out.println("bio.getCullmargin(): "+bio.getCullmargin());
		
		System.out.println("bio.getInterest(): "+bio.getInterest());
		System.out.println("bio.getP_loss(): "+bio.getP_loss());
		System.out.println("bio.getInvcullpct(): "+bio.getInvcullpct());
		System.out.println("bio.getFunk(): "+bio.getFunk());
		System.out.println("bio.getP_calf(): "+bio.getP_calf());
		System.out.println("bio.getP_fixed_labor(): "+bio.getP_fixed_labor());
		System.out.println("bio.getP_fixed_other(): "+bio.getP_fixed_other());
		System.out.println("bio.getP_other_dry(): "+bio.getP_other_dry());
		System.out.println("bio.getP_other_lact(): "+bio.getP_other_lact());
		
								
		System.out.println("bio.getP_tmrdmlac(): "+bio.getP_tmrdmlac());
		System.out.println("bio.getP_tmrdmdry(): "+bio.getP_tmrdmdry());
		System.out.println("bio.getDmi_dry(): "+bio.getDmi_dry());
		System.out.println("bio.getPctfat(): "+bio.getPctfat());
		System.out.println("bio.getPa_cv(): "+bio.getPa_cv());
		
		System.out.println("bio.getMilkrepeat(): "+bio.getMilkrepeat());
		System.out.println("bio.getP_labor(): "+bio.getP_labor());
		System.out.println("bio.getTimefresh(): "+bio.getTimefresh());
		System.out.println("bio.getTimelact(): "+bio.getTimelact());
								
		System.out.println("bio.getTimedry(): "+bio.getTimedry());
		for(int i=1; i<=4; i++){
			System.out.println("bio.getVetcost()["+i+"]: "+bio.getVetcost()[i]);
		}
		
			
		
		/**
		bio.getWritepol(1); 																							
		bio.getWriterpo(1); 																							
		startSeason = "JAN"; 																							
		policy = "OPTIMAL"; 																							
		bio.getMaxmim(24); 																							
		bio.getCullmilk(0); 																							
		bio.getCullmargin(-999); 																							
		bio.getInterest(0); 																							
		bio.getP_loss(0); 																							
		bio.getInvcullpct(0.8); 																							
		bio.getFunk(1); 																							
		bio.getP_calf(200); 																							
		bio.getP_fixed_labor(0.5); 																							
		bio.getP_fixed_other(2); 																							
		bio.getP_other_dry(0); 																							
		bio.getP_other_lact(0.2); 																							
		bio.getP_tmrdmlac(0.192); 																							
		bio.getP_tmrdmdry(0.096); 																							
		bio.getDmi_dry(12); 																							
		bio.getPctfat(3.5); 																							
		bio.getPa_cv(12); 																							
		bio.getMilkrepeat(0.6); 																							
		bio.getP_labor(10); 																							
		bio.getTimefresh(30); 																							
		bio.getTimelact(213); 																							
		bio.getTimedry(91); 																							
		bio.getVetcost()[1] = 38; 																							
		bio.getVetcost()[2] = 23; 																							
		bio.getVetcost()[3] = 8; 																							
		bio.getVetcost()[4] = 1; 																							
																									
																									
																									
		milk4[4] = 1; 	milk4[5] = 1; 	milk4[6] = 1; 	milk4[7] = 1; 	milk4[8] = 1; 	milk4[9] = 1; 	milk4[10] = 1; 	milk4[11] = 1; 	milk4[12] = 1; 															
		*/
				
			
	}
	
	
}
